<?php
	require 'libraries/CostLib.php';
	require 'libraries/UserLibrary.php';
	session_start();
	checkSessionVariable("administrator", "AdministratorHomepage.php", NULL);
?>

<html>
<head>
	<title>Edit Cost</title>
	<style type="text/css">
		div{
			color:red;
		}
	</style>
	<script type="text/javascript" src="scripts/validateCost.js"></script>
</head>
<body>
	<center>
	<br/>
	<form name="editCost" action="ProcessEditCost.php" method="post"  onsubmit= "return checkInput();">					
		<table border='0'>
			<tr>
				<th>ANALYSIS CATEGORY</th>
				<th>ANALYSIS COMPONENT</th>
				<th>PREVIOUS COST</th>
				<th>NEW COST</th>
			</tr>
			<?php 
			$con = mysql_connect('localhost','login','login') or die('Could not connect: ' . mysql_error());
			mysql_select_db('casl') or die(mysql_error());
			$result = mysql_query("SELECT MAIN_TYPE, SAMPLE_TYPE, ANALYSIS_TYPE, COST FROM COST_ANALYSIS");
			while($entry = mysql_fetch_array($result)){
			?>			
				<tr>
					<td><b><?php echo "$entry[1]";?></b></td>
					<td><?php echo "$entry[2]";?></td>
					<td><?php echo "$entry[3]";?></td>
					<td><input type="text" name='<?php echo str_replace(" ","_",$entry[2]);?>' value ="<?php echo "$entry[3]";?>"id="<?php echo "$entry[2]";?> Cost"/></td>
					<td><div id="errorAshCost"></div></td>
				</tr>	
			
			<?php
			}
			
			mysql_close($con);
			?>
			
		</table>
		
		<br/><br/>
		<input name="cost" id="cost" type="reset" value="CLEAR" />
		<input type="submit" name="cost" id="cost" value="SUBMIT"/>
		<br/>
	</form>
	</center>
</body>
</html>